#ifndef EXCEPTION_LOCAL_H
#define EXCEPTION_LOCAL_H

/*w Exception code customization.

The idea is you have an exception type (for example
AMBIGUITY_WARNING, and a bstring with the explanation, like
"No A register for domain whatever.com"
*/

#include "../bstrlib/bstrlib.h"

typedef enum { EXC_NONE, AMBIGUITY_WARNING, PERM_ERROR, TEMP_ERROR, ASSERTION_ERROR, UNIMPLEMENTED, EXC_OK } exception_type_t;

typedef struct {
  exception_type_t type;
  bstring param1;
} exception_t;

exception_t exception_make(exception_type_t type, bstring param1);

#define __EXC_TYPE                exception_t
#define __EXC_MAKE(type, param1)  exception_make(type, param1)
#define __EXC_ON(type)            exception_make(type, 0)
#define __EXC_EQ(a, b)            ((a).type == (b).type)
#define __EXC_PRINT(e, stream)    fprintf(stream, "%d:%s", e.type, e.param1->data)
#define EXCEPTION                 __exc_code

#undef __EXC_DEBUG

#include "exception.h"


#endif
